// Presets.js
// ====================

/* presets configuration array */
module.exports = [
	/* template for new presets */
	/*
	{
		name: 'preset name',
		types: ['extension1','extension2','extension3'],
		priority: 10,	// the highest priority for a file type get's executed first!
		destType: 'dest_extension',
		converterCmnd: './converter/my_converter %source% -myFlag %destination%'
	},
	*/
	
	{
		name: 'imagemagick picture 640x480',
		types: ['tif','tiff','jpg','jpeg','gif','png','nef','dng'],
		destType: 'jpg',
		converterCmnd: 'convert %source% -resize 640x480\> %destination%'
	},
	
	{
		name: 'Poppler picture 640',
		types: ['pdf'],
		destType: 'jpg',
		converterCmnd: 'pdftocairo -f 1 -scale-to 640 -jpeg -singlefile %source% %destination%',
		postFlight: function(destination) {
			/* we have to fix the filename */
			var wrongName = destination+".jpg";
			
			/* renaming file */
			var fs = require('fs');
			fs.renameSync(wrongName,destination);
		}
	},
	/*
	{
		name: 'qt_tools picture ~640x480',
		types: [],
		destType: 'png',
		converterCmnd: '/presstore-converter/converters/qt_tools/qt_export --replacefile -1 --loadsettings=/presstore-converter/converters/qt_tools/picture_640x480.setting %source% %destination%'
	},
	
	{
		name: 'qt_tools video ~640x480',
		types: ['mov'],
		destType: 'mov',
		priority: 10,
		converterCmnd: '/presstore-converter/converters/qt_tools/qt_export --replacefile -1 --loadsettings=/presstore-converter/converters/qt_tools/video_640x480.setting %source% %destination%'
	},
	*/
	{
		name: 'ffmpeg picture 640x480',
		types: [],//'tif','tiff','jpg','jpeg'
		destType: 'jpg',
		converterCmnd: 'ffmpeg -i %source% -s vga %destination%'
	},
	
	{
		name: 'ffmpeg audio 32kbit full',
		types: ['mp3','m4a','wav'],
		destType: 'mp3',
		converterCmnd: 'ffmpeg -i %source% -acodec libmp3lame -ab 32k -vn %destination%'
	},
	
	{
		name: 'ffmpeg audio 32kbit 60s',
		types: [],
		destType: 'mp3',
		converterCmnd: 'ffmpeg -i %source% -t 60 -acodec libmp3lame -ab 32k -vn %destination%'
	},
	
	{
		name: 'ffmpeg audio 32kbit 30s',
		types: [],
		destType: 'mp3',
		converterCmnd: 'ffmpeg -i %source% -t 30 -acodec libmp3lame -ab 32k -vn %destination%'
	},
	
	{
		name: 'ffmpeg audio 32kbit 10s',
		types: [],
		destType: 'mp3',
		converterCmnd: 'ffmpeg -i %source% -t 60 -acodec libmp3lame -ab 32k -vn %destination%'
	},
	
	{
		name: 'ffmpeg video 640x480 full',
		types: ['avi'],
		destType: 'mov',
		converterCmnd: 'ffmpeg -i %source% -acodec libmp3lame -ab 32k -b 64k -r 10 -vcodec libx264 -threads 0 -s vga %destination%'
	},

	// Avid MXF
	{
		name: 'ffmpeg video avix mfx 640x480 60s',
		types: ['mxf'],
		destType: 'mov',
		priority: 100,
		preFlight: function(source) {
			var basename=source.split(/[\\/]/).pop();
			//AudioMasteA02.C51E448F879D0.mxf
			var res = basename.match(/\S*(\S{1})\S{2}\.\S*\.mxf/);
			if (res!==null) {			
				if (res[1]=='A') {
					return false;
				}
			}
		},
		converterCmnd: 'ffmbc -i %source% -t 60 -acodec libmp3lame -ab 32k -b 64k -r 10 -vcodec libx264 -threads 0 -s vga %destination%'
	},
	
	{
		name: 'ffmpeg video 640x480 60s',
		types: ['mov','mxf','dv','mp4','wmv','flv','m2v','mpg'],
		destType: 'mov',
		converterCmnd: 'ffmpeg -i %source% -t 60 -acodec libmp3lame -ab 32k -b 64k -r 10 -vcodec libx264 -threads 0 -s vga %destination%'
	},
	
	{
		name: 'ffmpeg video 640x480 30s',
		types: [],
		destType: 'mov',
		converterCmnd: 'ffmpeg -i %source% -t 30 -acodec libmp3lame -ab 32k -b 64k -r 10 -vcodec libx264 -threads 0 -s vga %destination%'
	},
	
	{
		name: 'ffmpeg video 640x480 10s',
		types: [],
		destType: 'mov',
		converterCmnd: 'ffmpeg -i %source% -t 10 -acodec libmp3lame -ab 32k -b 64k -r 10 -vcodec libx264 -threads 0 -s vga %destination%'
	}
]
